using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Dimok.Data.DataSources;

namespace Data.DataSources {
	public class NotesDataSource : ObjectDataSourceBase {
		public override string SelectViewName { get { return "v_Note"; } }
		public override string InsertViewName { get { return "t_Note"; } }
		public int LoanID { get { return GetSelectParameterInt("LoanID"); } set { SetSelectParameter("LoanID", value); } }
		public bool ShowFlare { set { Filter = "StatusID = dbo.fs_StateID__Notes__Flare()"; } }
		protected override void OnInit(EventArgs e) {
			base.OnInit(e);
			Selecting += new ObjectDataSourceSelectingEventHandler(NotesDataSource_Selecting);
		}

		void NotesDataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) {
			if (GetSelectParameter(LOAN_ID) != null)
				SelectMethod = "SelectByLoanID";
			else SelectMethod = SELECT_METHOD;
		}
		public DataView SelectByLoanID(int LoanID) {
			return LoanID > 0 || Wheres() == "" ? Select("LoanID=@LoanID", LoanID) : SelectEx();
		}
	}
}